<?php

defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.controller');

class AreasController extends JController
{
        function __construct()
        {
                parent::__construct();
 
                // Register Extra tasks
                $this->registerTask( 'add'  ,   'edit', 'remove' );
        }
 
	/**
	 * Method to display the view
	 *
	 * @access	public
	 */
	function display()
	{
		parent::display();
	}

        function edit()
        {
                JRequest::setVar( 'view', 'area' );
                JRequest::setVar( 'layout', 'form'  );
                JRequest::setVar('hidemainmenu', 1);
 
                parent::display();
        }

        function add() {
		$this->edit();
	}

	function remove()
	{
		$model = $this->getModel('area');
		if(!$model->delete()) {
			$msg = JText::_( 'Error: Una o mas areas no pudieron ser borradas.' );
		} else {
			$msg = JText::_( 'Area(s) borrada(s)' );
		}

		$this->setRedirect( 'index.php?option=com_areas', $msg );
	}


}
